#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

typedef void(^PopupHandler)(void);

/*===================================================================
 标准视图控制器扩展
 ==================================================================*/
@interface UIViewController (Extension) <UINavigationBarDelegate, UIViewControllerPreviewingDelegate>

@property (nonatomic, readonly)	BOOL	created;	//控制器是否已创建过标志

@property (nonatomic, retain) UIViewController		*backViewController;	//目标返回控制器, 设置此属性在执行cancel时会POP到此控制器

//
+ (id)storyboardInitialWithName:(NSString *)name;
+ (id)storyboardWithName:(NSString *)name storyboardID:(NSString *)sid;		//在指定名称Storyboard中获取指定ID的控制器(若ID为nil,则返回初始控制器)

- (id)viewControllerWithStoryboardID:(NSString *)sid;						//在当前控制器所在的Storyboard中获取指定ID的控制器

- (void)registerForPreviewingWithView:(UIView *)sourceView;			//注册3DTouch（内部管理）
- (void)registerForLastPreviewing;
- (void)unregisterForPreviewing;

- (void)viewDidLanguage;

//子类可重载,重载时必须执行 [super view_xxx]
- (void)viewWillCreate;		//控制器加载完在首次显示前执行
- (void)viewWillDealloc;	//

- (IBAction)cancel;			//取消当前控制器, 会自动处理是POP还是Dismiss
- (void)cancelWithAnimated:(BOOL)animated;

//弹出非模式态窗口
+ (void)showViewController:(UIViewController *)target;
+ (UIWindow *)showViewController:(UIViewController *)target animated:(BOOL)animated handler:(PopupHandler)handler;

//显示模态窗口
- (void)showViewController:(UIViewController *)target;
- (void)showViewController:(UIViewController *)target after:(UIViewController *)viewController animated:(BOOL)animated;		//在完全显示控制器后, 原导航控制器会POP到after

//压入窗口
- (void)pushViewController:(UIViewController *)target;
- (void)pushViewController:(UIViewController *)target after:(UIViewController *)viewController;		//after设置backViewController

@end

/*===================================================================
 说明:
    自定视图控制器
 ==================================================================*/
@interface MRViewController : UIViewController

- (id)initWithTitle:(NSString *)title view:(UIView *)view;

@end
